package com.d5xx.hunters.events;

import com.d5xx.hunters.API.Hunter;
import com.d5xx.hunters.API.HunterPlayer;
import com.d5xx.hunters.scoreboard.LobbyScoreBoard;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;

import java.util.Objects;

public class PlayerJoin implements Listener {
    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        Player player = event.getPlayer();
        Objects.requireNonNull(player.getPlayer()).setGameMode(GameMode.ADVENTURE);
        HunterPlayer hunterPlayer = new HunterPlayer(player, "lobby");

        hunterPlayer.setScoreBoard(new LobbyScoreBoard(hunterPlayer));
        hunterPlayer.enableScoreboard();

        player.getInventory().clear();
        player.teleport(Hunter.getLobby());
    }
}
